﻿namespace HiMap.Carto
{
    using HiMap.Carto.Render;
    using HiMap.CoordinateSystem;
    using HiMap.Geometry;
    using System;

    public class FeatureLayerClass : LayerClass, IFeatureLayer, ILayer
    {
        public FeatureLayerClass(IFeatureClass Class)
        {
            base.m_class = Class;
        }

        bool IFeatureLayer.FeatureLayerAuto
        {
            get
            {
                return false;
            }
            set
            {
            }
        }

        bool IFeatureLayer.FeatureLayerIsAllowSameLabel
        {
            get
            {
                return HiMap.Carto.VC.KWG_LABEL_GET_ALLOWSAME(HiMap.Carto.VC.KWG_FEATURELAYER_GET_LABELCACHE(base.m_class.InPtr));
            }
            set
            {
                HiMap.Carto.VC.KWG_LABEL_SET_ALLOWSAME(HiMap.Carto.VC.KWG_FEATURELAYER_GET_LABELCACHE(base.m_class.InPtr), value);
            }
        }

        GeometryType IFeatureLayer.GeometryType
        {
            get
            {
                IFeatureClass class2 = new FeatureClassClass(base.m_class.InPtr, true);
                return class2.GeometryType;
            }
        }

        LabelArrangementType IFeatureLayer.LabelArrangementType
        {
            get
            {
                return (LabelArrangementType) HiMap.Carto.VC.KWG_LABEL_GET_ARRANGEMENTTYPE(HiMap.Carto.VC.KWG_FEATURELAYER_GET_LABELCACHE(base.m_class.InPtr));
            }
            set
            {
                HiMap.Carto.VC.KWG_LABEL_SET_ARRANGEMENTTYPE(HiMap.Carto.VC.KWG_FEATURELAYER_GET_LABELCACHE(base.m_class.InPtr), (int) value);
            }
        }

        int IFeatureLayer.LabelFontSize
        {
            get
            {
                return HiMap.Carto.VC.KWG_LABEL_GET_FONTSIZE(HiMap.Carto.VC.KWG_FEATURELAYER_GET_LABELCACHE(base.m_class.InPtr));
            }
            set
            {
                HiMap.Carto.VC.KWG_LABEL_SET_FONTSIZE(HiMap.Carto.VC.KWG_FEATURELAYER_GET_LABELCACHE(base.m_class.InPtr), value);
            }
        }

        int IFeatureLayer.LabelLevel
        {
            get
            {
                return HiMap.Carto.VC.KWG_LABEL_GET_LEVEL(HiMap.Carto.VC.KWG_FEATURELAYER_GET_LABELCACHE(base.m_class.InPtr));
            }
            set
            {
                HiMap.Carto.VC.KWG_LABEL_SET_LEVEL(HiMap.Carto.VC.KWG_FEATURELAYER_GET_LABELCACHE(base.m_class.InPtr), value);
            }
        }

        int IFeatureLayer.LableFieldIndex
        {
            get
            {
                return HiMap.Carto.VC.KWG_FEATURELAYER_GET_LABELINDEX(base.m_class.InPtr);
            }
            set
            {
                HiMap.Carto.VC.KWG_FEATURELAYER_SET_LABELINDEX(base.m_class.InPtr, value);
            }
        }

        double IFeatureLayer.MaxLabelVisibleScale
        {
            get
            {
                double scale = 0;
                HiMap.Carto.VC.KWG_FEATURELAYER_GET_LABEL_MAXSCALE(base.m_class.InPtr, ref scale);
                return scale;
            }
            set
            {
                HiMap.Carto.VC.KWG_FEATURELAYER_SET_LABEL_MAXSCALE(base.m_class.InPtr, value);
            }
        }

        double IFeatureLayer.MinLabelVisibleScale
        {
            get
            {
                double scale = 0;
                HiMap.Carto.VC.KWG_FEATURELAYER_GET_LABEL_MINSCALE(base.m_class.InPtr, ref scale);
                return scale;
            }
            set
            {
                HiMap.Carto.VC.KWG_FEATURELAYER_SET_LABEL_MINSCALE(base.m_class.InPtr, value);
            }
        }

        IProjection IFeatureLayer.Projection
        {
            get
            {
                return new Projection_GaussClass(HiMap.Carto.VC.KWG_FEATURELAYER_GET_PROJECTION(base.m_class.InPtr), true);
            }
            set
            {
                HiMap.Carto.VC.KWG_FEATURELAYER_SET_PROJECTION(base.m_class.InPtr, value.InPtr);
            }
        }

        IFeatureLayerRender IFeatureLayer.Render
        {
            get
            {
                int num = HiMap.Carto.VC.KWG_FEATURELAYER_GET_RENDER(base.m_class.InPtr);
                switch (HiMap.Carto.VC.KWG_RENDER_GET_TYPE(num))
                {
                    case 0:
                        return new FeatureLayerSimpleRenderClass(num, true);

                    case 1:
                        return new FeatureLayerGroupRenderClass(num, true);
                }
                return null;
            }
            set
            {
                HiMap.Carto.VC.KWG_FEATURELAYER_SET_RENDER(base.m_class.InPtr, value.InPtr);
                value.Used = true;
            }
        }
    }
}

